home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / source / xcode / sprites.asm < prev    next >
Encoding:
Assembly Source File  |  1993-10-18  |  3.0 KB  |  127 lines

  1.  
  2.         .286
  3.         IDEAL
  4.         LOCALS
  5.         MODEL    HUGE,C
  6.  
  7.  
  8.         CODESEG
  9.  
  10.         PUBLIC    fix_odd_width_bug
  11.         PUBLIC    separate_sprite_plane        
  12.  
  13. ;----------------------------------------------------------------------------:
  14. ; fix_odd_width_bug(&lbm_buffer)                                             :
  15. ; fixes lbm buffer so that it is without the padding provided by a             :
  16. ; bizzare deluxe pain feature                                                 :
  17. ;----------------------------------------------------------------------------:
  18.  
  19.  
  20. PROC    fix_odd_width_bug
  21.         ARG     lbm_buffer:DATAPTR
  22.         LOCAL    image_width:WORD,image_height:WORD
  23.         USES    ES,DI,DS,SI
  24.         
  25.         LES     DI,[lbm_buffer]
  26.         LDS     SI,[lbm_buffer]
  27.  
  28.         MOV     BX,[SI]                         ; prepare dimensions for 
  29.         MOV     CX,[SI+2]                        ; looping
  30.         INC     BX
  31.         INC     CX
  32.         MOV     [image_width],BX
  33.         MOV     [image_height],CX
  34.         
  35.         ADD     DI,4                            ; point to start of lbm 
  36.         ADD     SI,4                            ; data
  37.         
  38.         MOV     CX,[image_height]
  39. @@next_row:
  40.         PUSH    CX
  41.         MOV     CX,[image_width]
  42.         REP     MOVSB                            ; copy a row
  43.         INC     SI                                ; bump past padding
  44.         POP     CX
  45.         LOOP    SHORT @@next_row
  46.         RET
  47.         
  48. ENDP    fix_odd_width_bug
  49.  
  50. ;----------------------------------------------------------------------------:
  51. ; Seperate_Sprite_Planes                                                     :
  52. ; Assumes that a PCC file has been read in and decoded into Screen_Buffer     :
  53. ; Reads screen buffer into the image buffer plane by plane so that it may     :
  54. ; quickly be read/written                                                     :
  55. ; unsigned int separate_sprite_planes(source_buffer, desination_buffer,      :
  56. ;    plane_n):                                                                 :
  57. ; Returns width of plane in bytes                                             :
  58. ;----------------------------------------------------------------------------:
  59.  
  60. PROC    separate_sprite_plane
  61.         USES    BX,CX,DX,SI,DI,ES,DS
  62.         
  63.         ARG     Source:DATAPTR,Destination:DATAPTR,Plane:WORD
  64.         
  65.         LOCAL    Bytes_In_Plane_Row:WORD
  66.         LOCAL    Image_Width:WORD, Image_Height:WORD
  67.  
  68.         LDS     SI,[Source]
  69.         MOV     AX,[SI]
  70.         INC     AX
  71.         MOV     [Image_Width],AX
  72.         MOV     AX,[SI+2]
  73.         INC     AX
  74.         MOV     [Image_Height],AX
  75.         ADD     SI,4
  76.         ADD     SI,[Plane]
  77.                 
  78.         LES     DI,[Destination]                ; set up destination pointer
  79.         
  80.         ;
  81.         ; work out # of bytes in this plane
  82.         ;
  83.         MOV     CX,4
  84.         SUB     CX,[Plane]                        ; four planes
  85.         ; for each plane
  86. @@Next_Plane:        
  87.         ; work out # bytes in plane?
  88.         MOV     BX,[Image_Width]
  89.         ADD     BX,CX
  90.         DEC     BX
  91.         SHR     BX,2
  92.         MOV     [Bytes_In_Plane_Row],BX
  93.         MOV     CX,[Image_Height]
  94.          ; for each row
  95. @@Next_Row:
  96.         PUSH    CX
  97.         MOV     CX,[Bytes_In_Plane_Row]
  98.         PUSH    DI                                ; save start of dest row
  99.         PUSH    SI                                ; save start of sauce row
  100.         ; for each byte
  101. @@Next_Byte:
  102.         ; copy byte from sauce row to destination plane
  103.         MOVSB 
  104.         ADD     SI,3                            ; next sauce byte in plane
  105.           ; next byte
  106.         LOOP    @@Next_Byte
  107.          ; next row
  108.         POP     SI                                ; bump sauce to next image row
  109.         ADD     SI,[Image_Width]
  110.         TEST    [Image_Width],1
  111.         JZ        SHORT @@Not_Odd_Width
  112.         INC     SI
  113. @@Not_Odd_Width:
  114.         POP     DI
  115.         ADD     DI,[Bytes_In_Plane_Row]
  116.         POP     CX
  117.         LOOP    @@Next_Row 
  118.         ; next plane
  119.     
  120.         MOV     AX,[Bytes_In_Plane_Row]
  121.                             
  122.         RET     
  123. ENDP    separate_sprite_plane
  124.  
  125.  
  126.         END
  127.